package cn.ztuo.bitrade.dao;

import cn.ztuo.bitrade.dao.base.BaseDao;
import cn.ztuo.bitrade.entity.Relation;
import org.mapstruct.Mapping;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;


@Repository
public interface RelationDao extends BaseDao<Relation> {

    Relation findByUid(Long uid);
    Relation findByPidAndPosition(Long pid,int position);
    Relation findByUidAndPosition(Long uid,int position);
    List<Relation> findByPid(Long pid);
    List<Relation> findByParentLike(String parent);

    @Query(value ="select * from relation  where MATCH(parent) AGAINST (:par)",nativeQuery=true)
    List<Relation> findByParentMatch(@Param("par") String par);

    @Query(value ="select a.* from relation a where uid in (select member_id from cesspit_record where status='1')",nativeQuery = true)
    List<Relation> findAllMinerUser();
}
